/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package earleyalgorithm;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author NGOC
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException, IOException {
        // TODO code application logic here
        ArrayList<String> dict = Utility.readSentence("D:\\sentence1.txt");
        WordCollection wordClasses = new WordCollection();
        boolean flag = Utility.isDictionary("D:\\dictionary.txt", dict, wordClasses);
        Grammar r = Utility.readGrammar("D:\\grammar1.txt");
        EarlyAlgorithm ea = new EarlyAlgorithm(r, wordClasses, dict);
        ea.produceStartTable();
        String s = ea.getTables().get(0).toString();
        for(int i = 0; i < dict.size(); i++){
            ea.produceTable(dict.get(i),i + 1);
            String l = ea.getTables().get(i+1).toString();
            System.out.print(l);
        }

        ArrayList<Table> tables = ea.getTables();
        //String s = tables.get(0).toString();
        //System.out.print(s);
        for(int i = 1; i < dict.size(); i++) {
            String l = tables.get(i).toString();
            System.out.print(l);
        }
    }

}
